<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title language="html:userManagementPage"></title>
    <link rel="stylesheet" type="text/css" href="/static/common/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="/static/common/easyui/themes/bootstrap/easyui.css">
    <link rel="stylesheet" type="text/css" href="/static/common/easyui/themes/IconExtension.css">
    <link rel="stylesheet" href="/static/common/pnotify/pnotify.custom.min.css" media="all" type="text/css" />
    <link rel="stylesheet" type="text/css" href="/static/admin/css/admin.css">
    <link rel="stylesheet" href="/static/common/animate/animate.min.css">
</head>
<body onkeydown="hm.searchKey();">
<form>
    <div class="easyui-layout" style="padding:10px 0px 10px 10px;">
        <table id="hm_data" region="center"></table>
    </div>
    <div id="hm_toolbar">
        <a href="javascript:void(0)" onclick="hm.getVerify(this)" data-url="/intendant/site/addUser" class="easyui-linkbutton" iconCls="icon-add" plain="true" language="html:userAdd"></a>
        <a href="javascript:void(0)" onclick="hm.ajaxBatchDel(userDel,this)" data-url="/intendant/site/batchDelUser" class="easyui-linkbutton"  iconCls="icon-arrow_ns" plain="true" language="html:userBatchDel"></a>
        <a href="javascript:void(0)" onclick="hm.datagridReload('#hm_data','datagrid',userSearch,this)" class="easyui-linkbutton" iconCls="icon-2013040601125064_easyicon_net_16" plain="true" language="html:reloadDatagrid"></a>
    </div>
    <div id="hm_menu_tools">
        <form name="hm_search">
            <div class="hm_search">
                <span language="html:userSearch"></span>: <input type="text" name="username" class="easyui-validatebox" data-options="required:false,validType:['english','length[5,20]']"></input>
                <span language="html:userCreateTime"></span>: <input type="text" name="dateFrom" class="easyui-datetimebox" data-options="editable:false">
                <span language="html:userTo"></span>:<input type="text" name="dateTo" class="easyui-datetimebox" data-options="editable:false">
                <a href="#" onclick="hm.ajaxSearch(userSearch,this)" class="easyui-linkbutton" id="hm_search_submit" iconCls="icon-zoom" plain="true" language="html:search"></a>
                <a href="#" onclick="hm.clearSearch(this)" class="easyui-linkbutton" iconCls="icon-arrow_nw_ne_sw_se" plain="true" language="html:clearSearch"></a>
            </div>
        </form>
    </div>
</form>
</body>
<script type="text/javascript" src="/static/common/easyui/jquery.min.js"></script>
<script type="text/javascript" src="/static/common/easyui/jquery.cookie.js"></script>
<script type="text/javascript" src="/static/common/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/static/common/pnotify/pnotify.custom.min.js"></script>
<script type="text/javascript" src="/static/admin/js/language.js"></script>
<script type="text/javascript" src="/static/admin/js/global.js"></script>
<script>
var mehigh = document.documentElement.clientHeight-80;
$('#hm_data').datagrid({
    height: mehigh,
    // striped: true, //斑马线效果
    nowrap: false, //数据列是否显示为一行
    emptyMsg: hm.language.noData ? hm.language.noData : "no records data found",
    url:'/intendant/site/getUser',
    fitColumns: true, //宽度自适应窗口
    rownumbers: false, //是否显示行号
    singleSelect: false,
    scrollbarSize: 0, //去除滚动条，否则右边最后一列会自动多处一块
    remoteSort: false, //不以服务器端排序
    queryParams: null,//额外提交参数
    showHeader: true, //显示行头
    showFooter: true, //显示行尾
    pagination: true,
    pageSize: 20,             //分页大小
    pageNumber:1,             //从第几页开始显示（默认第一页，可以省略）
    pageList: [10, 20, 30, 40, 50],   //设置每页记录条数的列表
    pagePosition: 'bottom',
    toolbar: '#hm_menu_tools',
    rowStyler:function(index,row){//返回选定行的样式
        // if(row.role == "超级管理员"){
        //     return {class:'hm_datagrid_hl'};
        // }
    },
    columns:[[
        {
            field: 'ck',
            checkbox: true,
            width: 10,//百分比
            align: 'center',
        },{
            field: 'id',
            title: 'ID',
            width: 20,
            align: 'center',
            sortable: true,
        },{
            field: 'username',
            title: hm.language.userName,
            width: 60,
            align: 'center',
        },{
            field: 'role',
            title: hm.language.userRoleName,
            width: 60,
            align: 'center',
            formatter: function(value, row, index) {
                var lang = hm.getLanguage('datagird',value,row);
                return lang;
            }
        },{
            field: 'create_time',
            title: hm.language.userCreateTime,
            width: 75,
            align: 'center',
            formatter: function(value, row, index){
                return hm.dateFormat(value)
            },
            sortable: true,
        },{
            field: 'create_ip',
            title: hm.language.userCreateIp,
            width: 60,
            align: 'center',
        },{
            field: 'email',
            title: hm.language.userEmail,
            width: 60,
            align: 'center',
        },{
            field: 'remark',
            title: hm.language.remark,
            width: 40,
            align: 'center',
            formatter: function(value,row,index){
                if(value){
                    return '<a title="'+value+'" class="easyui-tooltip">'+hm.language.seeRemark+'</a>';
                }else{
                    return '<a title="'+hm.language.noRemark+'" class="easyui-tooltip">'+hm.language.seeRemark+'</a>';
                }
            }
        },{
            field: 'status',
            title: hm.language.isshow,
            width: 30,
            align: 'center',
            formatter: function(value, row, index) {
                if(value){
                    return '<i class="fa fa-check hm_fa_ok"></i>';
                }else{
                    return '<i class="fa fa-remove hm_fa_no"></i>';
                }
            }
        },{
            field: 'cz',
            title: hm.language.manageOperat,
            width: 120,
            align: 'center',
            formatter: function(value, row, index) {
                var str = '';
                if(row.id == 1){
                    str += '<a href="#" class="easyui-linkbutton hm-op-btn hm-red" iconCls="icon-2012080404218">'+hm.language.userAdminIsNo+'</a>';
                }else{
                    str += '<a href="javascript:void(0)" onclick="hm.getVerify(this)" data-url="/intendant/site/editUser/' + row.id + '" class="easyui-linkbutton hm-op-btn hm-blue" iconCls="icon-bookmark_edit">'+hm.language.ajaxEdit+'</a>';
                    str += '<a href="javascript:void(0)" onclick="hm.ajaxDel(userDel,this)" class="easyui-linkbutton hm-op-btn hm-red" iconCls="icon-delete" data-url="/intendant/site/delUser" data-id="' + row.id + '">'+hm.language.ajaxDel+'</a>';
                }
                return str;
            }
        }
    ]],
    onLoadSuccess: function(data) {
        if (data.status == 66) {
            window.location = '/intendant/auth';
        } else {
            $('.easyui-linkbutton').linkbutton();
            $('.easyui-tooltip').tooltip({
                position: 'bottom',
                onShow: function(){
                    $(this).tooltip('tip').css({
                        backgroundColor: '#f39c12',
                        borderColor: '#f39c12',
                        color: '#fff',
                        size: '18px',
                    });
                }
            });
        }
    }
});
hm.datagridResize("#hm_data",'datagrid'); //让treegrid宽度自动适应
function userDel(data){
    if (data.status == 11) {
        parent.hm.notice("error", data.info);
    } else if(data.status == 12){
        parent.hm.notice("error", hm.language.userAdminNoDel);
    } else if(data.status == 4){
        parent.hm.notice("error", hm.language.delFailed + data.info);
    } else if(data.status == 1){
        parent.hm.notice("success", hm.language.delSuccess );
        parent.hm.refreshTab();
    }else{
        parent.hm.notice("error", hm.language.unknownError);
    }
}
function userSearch(data){
    if (data.status == 11) {
        parent.hm.notice("warn",  data.info);
    } else if(data.status == 12){
        parent.hm.notice("warn",  data.info);
    } else if(data.status == 13){
        parent.hm.notice("warn",  data.info);
    } else if(data.status == 14){
        parent.hm.notice("warn",  data.info);
    } else if(data.status == 54){
        parent.hm.notice("warn", hm.language.noFoundData);
    } else if(data.status == 4){
        parent.hm.notice("error", hm.language.searchFailed + data.info);
    } else if(data.status == 1){
        parent.hm.notice("success", hm.language.searchSuccess );
        $('.easyui-linkbutton').linkbutton();
        $('.easyui-tooltip').tooltip({
            position: 'bottom',
            onShow: function() {
                $(this).tooltip('tip').css({
                    backgroundColor: '#f39c12',
                    borderColor: '#f39c12',
                    color: '#fff',
                    size: '18px',
                });
            }
        });
    }else{
        parent.hm.notice("error", hm.language.unknownError+data.info);
    }
}
</script>
</html>
